home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / OS Utilities / TimeZone.Daylight / InitMac.c next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  3.6 KB  |  158 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        InitMac.c
  3.  
  4.     Contains:    
  5.  
  6.     Written by:     
  7.  
  8.     Copyright:    Copyright © 1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 7/23/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23. #include <Dialogs.h>
  24. #include <Memory.h>
  25. #include <Windows.h>
  26. #include <QuickDraw.h>
  27. #include <Fonts.h>
  28. #include <GestaltEQU.h>
  29. #include <Traps.h>
  30. #include <TextEdit.h>
  31. #include <OSUtils.h>
  32.  
  33. #include "InitMac.h"
  34.  
  35. #define TrapMask 0x0800
  36.  
  37.  
  38. /*\
  39. |*| ---------------------------------------------------------------------
  40. |*| GLOBALS
  41. |*| ---------------------------------------------------------------------
  42. \*/
  43. SysEnvRec    TheWorld;
  44. Boolean        WNE_available;
  45. Boolean        HasGWorlds;
  46. Boolean        HasCQD;
  47.  
  48.  
  49.  
  50. /*\
  51. |*| ---------------------------------------------------------------------
  52. |*| NumToolboxTraps
  53. |*| ---------------------------------------------------------------------
  54. \*/
  55. short NumToolboxTraps (void)
  56. {
  57.     if (NGetTrapAddress(_InitGraf, ToolTrap) ==
  58.             NGetTrapAddress(0xAA6E, ToolTrap))
  59.         return(0x0200);
  60.     else
  61.         return(0x0400);
  62. }
  63.  
  64.  
  65. /*\
  66. |*| ---------------------------------------------------------------------
  67. |*| GetTrapType
  68. |*| ---------------------------------------------------------------------
  69. \*/
  70. TrapType GetTrapType (short theTrap)
  71. {
  72.     if ((theTrap & TrapMask) > 0)
  73.         return(ToolTrap);
  74.     else
  75.         return(OSTrap);
  76. }
  77.  
  78.  
  79. /*\
  80. |*| ---------------------------------------------------------------------
  81. |*| TrapAvailable
  82. |*| ---------------------------------------------------------------------
  83. \*/
  84. Boolean TrapAvailable (short theTrap)
  85. {
  86.  
  87.     TrapType    tType;
  88.  
  89.     tType = GetTrapType(theTrap);
  90.     if (tType == ToolTrap)
  91.         theTrap &= 0x07FF;
  92.     if (theTrap >= NumToolboxTraps())
  93.         theTrap = _Unimplemented;
  94.  
  95.     return (NGetTrapAddress(theTrap, tType) !=
  96.             NGetTrapAddress(_Unimplemented, ToolTrap));
  97. }
  98.  
  99.  
  100. /*\
  101. |*| ---------------------------------------------------------------------
  102. |*| WNEAvailable
  103. |*| ---------------------------------------------------------------------
  104. \*/
  105. Boolean WNEAvailable (void)
  106. {
  107.     return TrapAvailable(_WaitNextEvent);
  108. }
  109.  
  110.  
  111. /*\
  112. |*| ---------------------------------------------------------------------
  113. |*| CheckQuickDraw
  114. |*| ---------------------------------------------------------------------
  115. \*/
  116. void CheckQuickDraw (void)
  117. {
  118.     long      QDvers;  /* Version of QuickDraw on this machine */
  119.     
  120.     /* Find out if GWorlds and CQD are implemented on this machine */
  121.     Gestalt(gestaltQuickdrawVersion, &QDvers);
  122.  
  123.     HasGWorlds = (QDvers > gestaltOriginalQD && QDvers < gestalt8BitQD)
  124.                   || QDvers >= gestalt32BitQD;
  125.     
  126.     HasCQD = (QDvers >= gestalt8BitQD);
  127. }
  128.  
  129.  
  130. /*\
  131. |*| ---------------------------------------------------------------------
  132. |*| InitToolBox
  133. |*| ---------------------------------------------------------------------
  134. \*/
  135. void InitToolBox (short numberOfMasters)
  136. {
  137.     
  138.     InitGraf((Ptr) &qd.thePort);
  139.     InitFonts();
  140.     InitWindows();
  141.     InitMenus();
  142.     InitCursor();
  143.     TEInit();
  144.     FlushEvents(everyEvent, 0);
  145.     InitDialogs(nil);
  146.     
  147.     while(numberOfMasters--)
  148.         MoreMasters();
  149.         
  150.     MaxApplZone();
  151.     
  152.     SysEnvirons(1,&TheWorld);
  153.     
  154.     WNE_available = WNEAvailable();
  155.  
  156.     CheckQuickDraw ();
  157. }
  158.